home *** CD-ROM | disk | FTP | other *** search
/ Clickx 22 / Clickx 22.iso / DATA / amc_install.exe / {app} / Scripts / DVDPost (FR).ifs < prev    next >
Encoding:
Text File  |  2005-05-23  |  12.9 KB  |  375 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=ScorEpioN
  8. Title=DVDPost.be
  9. Description=Louez vos DVD en ligne sur www.dvdpost.be
  10. Site=http://www.dvdpost.be
  11. Language=FR
  12. Version=02 du 23/05/2005
  13. Requires=3.5
  14. Comments=Ce script nΘcessite le fichier ScorEpioNCommonScript.pas|.==.| :   ' ( ( ( ( /\ |  "==()))))):     ⌐ ScorEpioN ⌐|       ( ( ( ( \_/
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. Mise α jour=1|1|0=Oui|1=Non
  20. Type de Lancement=0|0|0=Demande le titre avant de lancer le script|1=Ne demande pas le titre avant de lancer le script|2=Cherche le meilleur rΘsultat sans confirmation|3=Lancement automatique sur l'adresse web
  21. Casse Choisie=3|3|0=Titre et Nom en minuscule|1=Titre et Nom en majuscule|2=PremiΦre lettre en majuscule|3=PremiΦre lettre de chaque mot en majuscule
  22. Titre en double=0|0|0=Garde les titres originaux et traduits mΩme identiques|1=Garde les titres originaux si identiques|2=Garde les titres traduits si identiques
  23. Recherche sur le titre=0|0|0=Traduit|1=Original
  24. Note=0|0|0=Moyenne DVDPost & Internautes|1=DVDPost|2=Internautes
  25. Fichier de log=1|1|0=Oui|1=Non
  26.  
  27. ***************************************************)
  28.  
  29. program DVDPost_FR;
  30. uses
  31.   ScorEpioNCommonScript;
  32.  
  33. const
  34.      VersionScript = '02 du 23/05/2005';
  35.      NomScript = 'DVDPOST';
  36.      urlDomain = 'dvdpost.be';
  37.      urlBase = 'http://www.dvdpost.be/';
  38.      urlSearch = urlBase+'advanced_search_result2.php?keywords=';
  39.      urlImage = 'http://images.dvdpost.be//dvd/';
  40.      timeSleep = 500;
  41. var
  42.   MovieName, Address : string;
  43.   i, premiereExecution : Integer;
  44.   listeResultat: TStringList;
  45.  
  46. //------------------------------------------------------------------------------
  47. // RECUPERE LES RESULTATS DVDPost.be
  48. //------------------------------------------------------------------------------
  49.  
  50. procedure recherche(title : String);
  51. var
  52.   Line, titre, adresse : String;
  53.   StartPos, EndPos : Integer;
  54. begin
  55.   Line := GetPage(urlSearch+UrlEncode(title));
  56.   if pos('<b>DVD</b><br><table width="100%"></table>', Line) = 0 then
  57.   begin
  58.     listeResultat := TStringList.Create;
  59.     StartPos := pos('<b>DVD</b>', Line);
  60.     delete(Line, 1, StartPos+length('<b>DVD</b>')-1);
  61. // RΘcupΘre les rΘsultats
  62.     StartPos := pos('<a href="', Line);
  63.     delete(Line, 1, StartPos-1);
  64.     repeat
  65. {*********************** Boucle DEBUT ***********************}
  66.      StartPos := pos('<a href="', Line);
  67.      delete(Line, 1, StartPos-1);
  68. {*********************** Boucle DEBUT ***********************}
  69.      adresse := urlBase+findInfo('<a href="', '"', Line,'0');
  70.      titre := findInfo('<u>', '</u>', Line,'0');
  71. // Ajoute les films
  72.      listeResultat.Add(titre+'|'+adresse);
  73. {*********************** Boucle FIN ***********************}
  74.      delete(Line, 1, length('<a href="'));
  75.      EndPos := pos('<b>Acteurs</b>', Line);
  76.      StartPos := pos('<a href="', Line);
  77. {*********************** Boucle FIN ***********************}
  78.     until (StartPos > EndPos);
  79.  
  80. // CrΘation de la liste de rΘsultats
  81.     afficheResultat(title);
  82.   end else
  83.   begin
  84.     SetField(fieldChecked, '');
  85.     exit;
  86.   end;
  87. end;
  88.  
  89. //------------------------------------------------------------------------------
  90. // CREATION DE LA LISTE DE RESULTAT
  91. //------------------------------------------------------------------------------
  92.  
  93. procedure afficheResultat(title : String);
  94. var
  95.    StartPos: Integer;
  96.    couple, titre, adresse : String;
  97. begin
  98.  
  99.   if (GetOption('Type de Lancement') = 0) or (GetOption('Type de Lancement') = 1) then
  100.   begin
  101.    PickTreeClear;
  102.    PickTreeAdd('Films trouvΘs pour ' + title + ' :', '');
  103.    for i:=0 to listeResultat.Count-1 do
  104.    begin
  105.      couple := listeResultat.GetString(i);
  106.      titre := copy(couple,0,pos('|',couple)-1);
  107.      delete(couple, 1, length(titre)+1);
  108.      HTMLDecode(titre);
  109.      adresse := copy(couple,0,length(couple));
  110.      delete(couple, 1, length(adresse)+1);
  111.      PickTreeAdd(titre, adresse);
  112.    end;
  113.  
  114.    if listeResultat.Count = 1 then
  115.    begin
  116.      recupInfo(adresse);
  117.      exit;
  118.    end;
  119.  
  120.     begin
  121.       if PickTreeExec(Address)=true then
  122.       begin
  123.           recupInfo(Address);
  124.       end;
  125.     end;
  126.   end else if (GetOption('Type de Lancement') = 2) then
  127.   begin
  128.    if listeResultat.Count = 1 then
  129.    begin
  130.      couple := listeResultat.GetString(0);
  131.      titre := copy(couple,0,pos('|',couple)-1);
  132.      delete(couple, 1, length(titre)+1);
  133.      HTMLDecode(titre);
  134.      adresse := copy(couple,0,length(couple));
  135.      delete(couple, 1, length(adresse)+1);
  136.      recupInfo(adresse);
  137.      exit;
  138.    end else
  139.    begin
  140.      trouveTitle(title);
  141.    end;
  142.   end;
  143. end;
  144.  
  145. //------------------------------------------------------------------------------
  146. // RECUPERE LES INFOS
  147. //------------------------------------------------------------------------------
  148.  
  149. procedure recupInfo(Adresse : String);
  150. var
  151.    Value, Value2, Line: String;
  152.    StartPos : Integer;
  153. begin
  154. // Pour le mode Batch
  155.    if (GetOption('Fichier de log') = 0) then
  156.      beforeUpdate();
  157. // Importe la page
  158.    Sleep(timeSleep);
  159.    Line := GetPage(Adresse);
  160. // Jaquette DVD
  161.    if CanSetPicture then
  162.      MonGetPicture(urlImage+findInfo(urlImage, '"', Line,'0'));
  163. // Titre Traduit
  164.    if CanSetField(fieldTranslatedTitle) or CanSetField(fieldYear) then
  165.    begin
  166.      Value := findInfo('#75757A;font-weight:bold">', '</TD>', Line,'0');
  167.      Value2 := findInfo('( ', ' )', Value,'0');
  168.      Value := StringReplace(Value, '( '+Value2+' )', '');
  169.      MonSetField(fieldTranslatedTitle, formatTitre(Trim(Value),GetOption('Casse Choisie')));
  170.      MonSetField(fieldYear, Value2);
  171.    end;
  172. {// Titre Original
  173.    if CanSetField(fieldOriginalTitle) then
  174.       MonSetField(fieldOriginalTitle, formatTitre(findInfo('Titre original</b></td>', '</td>', Line,'0'),GetOption('Casse Choisie')));}
  175. // Genre
  176.    if CanSetField(fieldCategory) then
  177.    begin
  178.       Value := findInfo(';color:gray">', '</TD>', Line,'-1');
  179.       Value := StringReplace(Value, ' | ', ',');
  180.       Value := StringReplace(Value, '/', ' ');
  181.       Value := StringReplace(Value, #13#10, ', ');
  182.       Value := StringReplace(Value, ' ,', ',');
  183.       Value := StringReplace(Value, ',,', ',');
  184.       Value := StringReplace(Value, ',                   ', '');
  185.       MonSetField(fieldCategory, formatTitre(deleteEnd(Value,', '),GetOption('Casse Choisie')));
  186.    end;
  187. // DurΘe
  188.    if CanSetField(fieldLength) then
  189.       MonSetField(fieldLength, findInfo('<B>DurΘe:', '</TD>', Line,'0'));
  190. // Acteurs
  191.    if CanSetField(fieldActors) then
  192.    begin
  193.       Value := findInfo('<B>Acteurs:', '</td>', Line,'0');
  194.       Value := StringReplace(Value, ' , ', ',');
  195.       Value := StringReplace(Value, ' ,', '.');
  196.       MonSetField(fieldActors, formatTitre(Value,GetOption('Casse Choisie')));
  197.    end;
  198. // RΘalisateur
  199.    if CanSetField(fieldDirector) then
  200.    begin
  201.       Value := findInfo('<B>RΘalisateur:', '</td>', Line,'0');
  202.       Value := StringReplace(Value, ' , ', ',');
  203.       Value := StringReplace(Value, ' ,', '.');
  204.       MonSetField(fieldDirector, formatTitre(Value,GetOption('Casse Choisie')));
  205.    end;
  206. // ScΘnario
  207.    if CanSetField(fieldDescription) then
  208.       MonSetField(fieldDescription, findInfo('<td class="boxText" align="left">', '</TR>', Line,'0'));
  209. // Studio
  210.    if CanSetField(fieldProducer) then
  211.       MonSetField(fieldProducer, findInfo('<B>Studio:', '</TD>', Line,'0'));
  212. // Note
  213.    if CanSetField(fieldRating) then
  214.    begin
  215.       Value := FormatFloat(FloatToStr(StrToFloat(findInfo('starbar/stars_1_', '.gif', Line,'0'))/5));       // Note DVDPost
  216.       Value2 := FormatFloat(FloatToStr(StrToFloat(findInfo('Cotation moyenne: <b>', '</b>', Line,'0'))*2)); // Note Internautes
  217.       if (GetOption('Note') = 0) then
  218.       begin
  219.          if Value2 <> '0.0' then
  220.            MonSetField(fieldRating, FloatToStr((StrToFloat(Value)+StrToFloat(Value2))/2))
  221.          else
  222.            MonSetField(fieldRating, Value);
  223.       end else if (GetOption('Note') = 1) then
  224.       begin
  225.          MonSetField(fieldRating, Value);
  226.       end else if (GetOption('Note') = 2) then
  227.       begin
  228.          MonSetField(fieldRating, Value2);
  229.       end;
  230.    end;
  231. // Adresse Web
  232.   if CanSetField(fieldURL) then
  233.       MonSetField(fieldURL, Adresse);
  234. // Public
  235.   if CanSetField(fieldComments) then
  236.   begin
  237.       Value := findInfo('<b>Public:', '</TD>', Line,'1');
  238.       Value := findInfo('.be//', '.gif', Value,'0');
  239.       if Value <> '' then
  240.         Value := 'Public : '+AnsiUpperCase(Value);
  241.       MonSetField(fieldComments, Value);
  242.   end;
  243.  
  244. // Pour le mode Batch
  245.   if (GetOption('Fichier de log') = 0) then
  246.     afterUpdate();
  247.  
  248. // Affichage des titres si original et traduit identique
  249.   titreDouble(GetOption('Titre en double'));
  250.  
  251. end;
  252.  
  253. //------------------------------------------------------------------------------
  254. // SUPPRIME LES ACCENTS
  255. //------------------------------------------------------------------------------
  256.  
  257. function supprimeAccents(NomFilm : String) : String;
  258. begin
  259. // les accents
  260.      NomFilm := supprimeLesAccents(NomFilm);
  261. // Pour n'avoir que le titre
  262.      delete(NomFilm, pos(' - ',NomFilm), length(NomFilm));
  263.      if (pos(', ',NomFilm) > 0) then
  264.         delete(NomFilm, 1, pos(', ',NomFilm)+1);
  265.      if (pos('(',NomFilm) > 0) then
  266.         delete(NomFilm, pos('(',NomFilm), length(NomFilm));
  267.      if (pos(':',NomFilm) > 0) then
  268.         delete(NomFilm, pos(':',NomFilm), length(NomFilm));
  269.      result := trim(NomFilm);
  270. end;
  271.  
  272. //------------------------------------------------------------------------------
  273. // COMPARE LE TITRE PASSE ET LE TITRE TROUVE
  274. //------------------------------------------------------------------------------
  275.  
  276. function compareTitle(titleAllo, title : String) : String;
  277. begin
  278.      title := supprimeAccents(trim(AnsiLowerCase(title)));
  279.      titleAllo := supprimeAccents(trim(AnsiLowerCase(titleAllo)));
  280.      if (title = titleAllo) then
  281.      begin
  282.        result := 'OK';
  283.      end else
  284.      begin
  285.        result := 'KO';
  286.      end;
  287. end;
  288.  
  289. //------------------------------------------------------------------------------
  290. // TROUVE LE BON TITRE SI LE PREMIER N'EST PAS LE BON
  291. //------------------------------------------------------------------------------
  292.  
  293. procedure trouveTitle(title : String);
  294. var
  295.    oK, couple, titre, adresse : String;
  296. begin
  297.    for i:=0 to listeResultat.Count-1 do
  298.    begin
  299.      couple := listeResultat.GetString(i);
  300.      titre := copy(couple,0,pos('|',couple)-1);
  301.      delete(couple, 1, length(titre)+1);
  302.      HTMLDecode(titre);
  303.      adresse := copy(couple,0,length(couple));
  304.      delete(couple, 1, length(adresse)+1);
  305.      oK := compareTitle(title,titre);
  306.      if oK = 'OK' then
  307.      begin
  308.        recupInfo(adresse);
  309.        exit;
  310.      end;
  311.    end;
  312.    listeResultat.Free;
  313.  
  314. end;
  315.  
  316. //------------------------------------------------------------------------------
  317. // PROGRAMME PRINCIPAL
  318. //------------------------------------------------------------------------------
  319.  
  320. begin
  321.   if CheckVersion(3,5,0) then
  322.   begin
  323.     if GetOption('Mise α jour') = 0 then
  324.     begin
  325.        execMenuMAJ(VersionScript,NomScript);
  326.        exit;
  327.     end;
  328.     MovieName := recupTitreRecherche(GetOption('Recherche sur le titre'));
  329.     Sleep(timeSleep);
  330.     if (GetOption('Fichier de log') = 0) and (premiereExecution = 0) then
  331.     begin
  332.       batch(NomScript);
  333.       AddToLog('Les films ayant ΘtΘ mis α jour sont maintenant cochΘs');
  334.     end;
  335.     if (GetOption('Type de Lancement') = 0) then
  336.     begin
  337.       if Input(NomScript+' by ScorEpioN', 'Entrez le titre du film :', MovieName) then
  338.       begin
  339.         if Pos(urlDomain, MovieName) > 0 then
  340.         begin
  341.           recupInfo(MovieName);
  342.         end else
  343.           recherche(MovieName);
  344.       end;
  345.     end else
  346.     if (GetOption('Type de Lancement') = 3) then
  347.     begin
  348.       if (premiereExecution = 0) then
  349.       begin
  350.         premiereExecution := -1;
  351.         if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = False) then
  352.            exit;
  353.       end;
  354.       MovieName := GetField(fieldURL);
  355.       if Pos(urlDomain, MovieName) > 0 then
  356.          recupInfo(MovieName);
  357.     end else
  358.     begin
  359.       if (premiereExecution = 0) then
  360.       begin
  361.           premiereExecution := -1;
  362.           if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = True) then
  363.           begin
  364.             recherche(MovieName);
  365.           end else
  366.             exit;
  367.       end else
  368.       begin
  369.           recherche(MovieName);
  370.       end;
  371.     end;
  372.   end else
  373.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  374. end.
  375.